package edu.hitsz.aircraft;

import edu.hitsz.application.Main;
import edu.hitsz.bullet.BaseBullet;
import edu.hitsz.bullet.EnemyBullet;

import java.util.LinkedList;
import java.util.List;

public class Boss extends MobEnemy{
    /**攻击方式 */

    /**
     * 子弹一次发射数量
     */

    private int shootNum = 20;
    /**
     * 子弹伤害
     */
    private int power = 30;

    /**
     * 子弹射击方向 (向上发射：1，向下发射：-1)
     */
    private  int direction = 1;
    public Boss(int locationX, int locationY, int speedX, int speedY, int hp) {
        super(locationX, locationY, speedX, speedY, hp);
    }

    @Override
    public void forward() {
        super.forward();
        // 判定 y 轴向下飞行出界
        if (locationY >= Main.WINDOW_HEIGHT ) {
            vanish();
        }
    }

    @Override
    public List<BaseBullet> shoot() {
        List<BaseBullet> res = new LinkedList<>();
        int x = this.getLocationX();
        int y = this.getLocationY() + direction*2;
        BaseBullet bullet;
        int speedX = 0;
        int speedY = this.getSpeedY() + direction*5;
        for(int i=0; i<shootNum; i++){
            double radians = Math.toRadians(18 * i);
            System.out.println("cos = " + Math.cos(radians) + '\n');
            int location_x = (int)(x + 200*Math.cos(radians));
            int location_y = (int)(y + 200*Math.sin(radians) - 50);
            bullet = new EnemyBullet(location_x, location_y, speedX, speedY, power);
            res.add(bullet);
        }

        return res;
    }
}
